using Core.Extensions;

namespace Core
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using Attributes;
    using Base;
    using Contracts.Enums;
    using Contracts.Interfaces;

    /// <summary>
    /// Agent class
    /// </summary>
    public sealed class Agent : AgentBase, IEquatable<Agent>
    {
        /// <summary>
        /// Construct a new agent with all attributes and extensions to 0
        /// </summary>
        /// <returns></returns>
        public static Agent CreateNew(string name)
        {
            return new Agent(
                string.IsNullOrEmpty(name) ? Resources.Traduction.label_new_agent : name,
                GetExtensions());
        }
        /// <summary>
        /// Obtains all extensions
        /// </summary>
        /// <returns></returns>
        private static IEnumerable<IExtension> GetExtensions()
        {
            return new IExtension[]
                       {
                           new AcceleratedArmorRepair(),
                           new AcceleratedReloading(),
                           new AcceleratedTargetLocking(),
                           new Accounting(),
                           new AccumulatorExpansion(),
                           new AdvancedBallistics(),
                           new AdvancedCorporationManagement(),
                           new AdvancedEfficientMassProduction(),
                           new AdvancedEfficientPrototypeProduction(),
                           new AdvancedExtensiveMassProduction(),
                           new AdvancedExtensiveReverseEngineering(),
                           new AdvancedFactoryCalibration(),
                           new AdvancedGeology(),
                           new AdvancedIntensiveHarvesting(),
                           new AdvancedIntensiveMining(),
                           new AdvancedIntensivePrototypeProduction(),
                           new AdvancedIntensiveReverseEngineering(),
                           new AdvancedKinematics(),
                           new AdvancedMagnetostatics(),
                           new AdvancedMarketing(),
                           new AdvancedOptics(),
                           new AdvancedPurchasing(),
                           new AdvancedRobotics(),
                           new AdvancedSquadManagement(),
                           new ArtifactScanning(),
                           new BasicBallistics(),
                           new BasicCorporationManagement(),
                           new BasicEfficientMassProduction(),
                           new BasicEfficientPrototypeProduction(),
                           new BasicExtensiveMassProduction(),
                           new BasicExtensivePrototypeProduction(),
                           new BasicExtensiveReverseEngineering(),
                           new BasicFactoryCalibration(),
                           new BasicGeochemistry(),
                           new BasicGeology(),
                           new BasicIntensiveHarvesting(),
                           new BasicIntensiveMining(),
                           new BasicIntensivePrototypeProduction(),
                           new BasicIntensiveReverseEngineering(),
                           new BasicKinematics(),
                           new BasicMagnetostatics(),
                           new BasicMarketing(),
                           new BasicOptics(),
                           new BasicParallelAssignments(),
                           new BasicPurchasing(),
                           new BasicRepairTechnologies(),
                           new BasicRobotics(),
                           new BasicSquadManagement(),
                           new CalibrationTemplateExtractionEfficiency(),
                           new ComplexJammingElectronics(),
                           new ComplexMechanics(),
                           new ComplexMissileLaunch(),
                           new ConvergentElectrostatics(),
                           new CriticalHit(),
                           new DataProcessing(),
                           new Demobilization(),
                           new Diplomacy(),
                           new EconomicIndustrialEngineering(),
                           new EconomicalArmorUsage(),
                           new EconomicalShieldUsage(),
                           new EconomicalWeaponUsage(),
                           new EfficientECMTechnology(),
                           new EfficientEnergyTransfer(),
                           new EfficientHarvesting(),
                           new EfficientMining(),
                           new EnergyManagement(),
                           new ExpandedInsuranceQuota(),
                           new ExpertCorporationManagement(),
                           new ExpertEfficientMassProduction(),
                           new ExpertEfficientPrototypeProduction(),
                           new ExpertExtensiveMassProduction(),
                           new ExpertExtensiveReverseEngineering(),
                           new ExpertFactoryCalibration(),
                           new ExpertIntensiveMining(),
                           new ExpertIntensivePrototypeProduction(),
                           new ExpertIntensiveReverseEngineering(),
                           new ExpertMarketing(),
                           new ExpertPurchasing(),
                           new ExtensiveAgriculture(),
                           new ExtensiveEpritonMining(),
                           new ExtensiveHDTExploitation(),
                           new ExtensiveHelioptrisHarvesting(),
                           new ExtensiveImentiumMining(),
                           new ExtensiveLiquizitMining(),
                           new ExtensiveMining(),
                           new ExtensiveNoralgisHarvesting(),
                           new ExtensiveStermonitMining(),
                           new ExtensiveTitanMining(),
                           new ExtensiveTriandlusHarvesting(),
                           new GeneralFiring(),
                           new HeadhunterBonus(),
                           new HighgradeRecycling(),
                           new ImprovedArmorRepair(),
                           new ImprovedEnergyDrain(),
                           new ImprovedEnergyNeutralization(),
                           new ImprovedFalloff(),
                           new ImprovedShieldTechnology(),
                           new IndustrialRobotControl(),
                           new IndustrialSpecialization(),
                           new IntensiveEpritonMining(),
                           new IntensiveHDTExploitation(),
                           new IntensiveImentiumMining(),
                           new IntensiveLiquizitMining(),
                           new IntensiveMassProduction(),
                           new IntensiveStermonitMining(),
                           new IntensiveTitanMining(),
                           new InterferenceModulation(),
                           new JammingElectronics(),
                           new LogisticsSpecialization(),
                           new LongDistanceElectronicWarfare(),
                           new LongRangeEngineering(),
                           new LongRangeTargeting(),
                           new LongtermInsurance(),
                           new Mechanics(),
                           new MissileGuidance(),
                           new MissileLaunch(),
                           new Navigation(),
                           new NexusAcceleratedTargetLocking(),
                           new NexusAccumulatorRecharge(),
                           new NexusArmorRepair(),
                           new NexusAssault(),
                           new NexusCriticalHit(),
                           new NexusDefense(),
                           new NexusElectronicWarfare(),
                           new NexusFastExtraction(),
                           new NexusHitEvasion(),
                           new NexusImprovedShieldTechnology(),
                           new NexusIndustrial(),
                           new NexusLongRangeTargeting(),
                           new NexusNavigation(),
                           new NuimqolRobotControl(),
                           new OptimizedArmorUsage(),
                           new OptimizedElectronicWarfare(),
                           new OptimizedEngineering(),
                           new OptimizedIndustrialEngineering(),
                           new OptimizedShieldUsage(),
                           new OptimizedSignalDetection(),
                           new OptimizedSignalMasking(),
                           new OptimizedWeaponUsage(),
                           new PelistalRobotControl(),
                           new PrecisionFiring(),
                           new ProgrammedMassProduction(),
                           new PropellantMixing(),
                           new Rapidfiring(),
                           new ReactorExpansion(),
                           new Recycling(),
                           new Refining(),
                           new RemoteArmorRepair(),
                           new RemoteSensorAmplification(),
                           new Research(),
                           new Seismics(),
                           new SensorConnection(),
                           new SensorSuppressing(),
                           new Sharpshooting(),
                           new SignalDetection(),
                           new SignalMasking(),
                           new SpecOpsRobotControl(),
                           new TacticsSpecialization(),
                           new TargetAnalysis(),
                           new Targeting(),
                           new TaxReduction(),
                           new ThelodicaRobotControl(),
                       };
        }
        /// <summary>
        /// Create a new instance of the <see cref="T:Core.Agent"/> class.
        /// </summary>
        private Agent(string name, IEnumerable<IExtension> extensions) 
            : base(name, extensions)
        {
        }

        /// <summary>
        /// Obtains the agent tactics level attribute
        /// </summary>
        [Obsolete]
        public uint TacticsLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent mechatronic level attribute
        /// </summary>
        [Obsolete]
        public uint MechatronicsLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent industry level attribute
        /// </summary>
        [Obsolete]
        public uint IndustryLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent research level attribute
        /// </summary>
        [Obsolete]
        public uint ResearchLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent politics level attribute
        /// </summary>
        [Obsolete]
        public uint PoliticsLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent economics level attribute
        /// </summary>
        [Obsolete]
        public uint EconomicsLevel
        {
            get { return 0; }
            set { }
        }
        /// <summary>
        /// Obtains the agent corporation extensions list
        /// </summary>
        public IEnumerable<IExtension> CorporationExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Corporation).OrderBy(e=>e.Name); }

        }
        /// <summary>
        /// Obtains the agent Electronics extensions list
        /// </summary>
        public IEnumerable<IExtension> ElectronicsExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Electronics).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent Engineering extensions list
        /// </summary>
        public IEnumerable<IExtension> EngineeringExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Engineering).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent Finances extensions list
        /// </summary>
        public IEnumerable<IExtension> FinancesExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Finances).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent Industry extensions list
        /// </summary>
        public IEnumerable<IExtension> IndustryExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Industry).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent MaterialExtraction extensions list
        /// </summary>
        public IEnumerable<IExtension> MineralExtractionExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.MineralExtraction).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent NexusManagement extensions list
        /// </summary>
        public IEnumerable<IExtension> NexusManagementExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.NexusManagement).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent Relations extensions list
        /// </summary>
        public IEnumerable<IExtension> RelationsExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.Relations).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent RobotControl extensions list
        /// </summary>
        public IEnumerable<IExtension> RobotControlExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.RobotControl).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Obtains the agent WeaponUsage extensions list
        /// </summary>
        public IEnumerable<IExtension> WeaponUsageExtensions
        {
            get { return Extensions.Where(e => e.Group == ExtensionGroupsEnum.WeaponUsage).OrderBy(e => e.Name); }
        }
        /// <summary>
        /// Indicates whether the current object is equal to another object of the same type.
        /// </summary>
        /// <returns>
        /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
        /// </returns>
        /// <param name="other">An object to compare with this object.</param>
        public bool Equals(Agent other)
        {
            return base.Equals(other);
        }
    }
}